#!/bin/bash
# -*- encoding: utf8 -*-
from BModel.AddHistoryHive import OldDataInsertHive, NewDataInsertHive
from BModel.IncrementAddHive import AddDataInsertHive
from core.Mysqldb import MyDB
from core.writeLog import LogController
from BModel.IncrementAdd import AddDataInsert

if __name__ == "__main__":
    """脚本切换测试或online"""
    # dbtype = "online"
    print '加载online'
    dbtype = "ontest"

    """脚本切换添加新数据和历史数据"""
    # runtype = "add"
    runtype = "history"

    """调用MyDB函数选择数据库"""
    db = MyDB(dbtype)
    print '加载数据库ok'

    """判断调用的历史区间或数据更新区间"""
    if 'history' == runtype:
        # log = LogController('F:/twsidom/project/SourceOrder/log/Hive_history.txt')
        # log.writeLog("开始进行历史数据导入")

        """处理老数据方法"""
        OldDataInsertHive(db)
        print '数据库准备ok'
        # log.writeLog("携程接口升级之前数据补充完成")

        """处理新数据方法"""
        # NewDataInsertHive(db)
        # log.writeLog("携程接口升级之后数据补充完成")
    else:
        # log = LogController('F:/twsidom/project/SourceOrder/log/Hive_history.txt')
        # log.writeLog("开始更新")

        """添加新数据方法"""
        AddDataInsertHive(db)
        # log.writeLog("更新结束")
